<template>
	<el-dialog v-model="dialogVisible" title="提交修改申请">
		<div v-loading="loading">
			<HyForm ref="hyFormRef" :hyFormConfig="hyFormConfig" :hyFormFields="hyFormFields" />
		</div>
		<template #footer>
			<div class="dialog-footer">
				<el-button @click="dialogVisible = false">取消</el-button>
				<el-button type="primary" @click="handleOk" :loading="loading"> 确定 </el-button>
			</div>
		</template>
	</el-dialog>
</template>
<script setup lang="ts">
import HyForm from '/@/components/HyForm/index.vue';
import { threeListEditApi } from '/@/api/threeList/declare';

const props = defineProps({
	businessKey: {
		type: String,
		default: '',
	},
	businessType: {
		type: String,
		default: '',
	},
});
const dialogVisible = ref(false);
const hyFormFields = ref({
	applyReason: {
		label: '申请修改理由',
		type: 'textarea',
		required: true,
	},
});
const hyFormConfig = computed(() => {
	return {
		labelWidth: '120px',
		span: 22,
		offset: 0,
		type: 'submit',
	};
});
const hyFormRef = ref();
const loading = ref(false);
const emits = defineEmits(['sendValue']);
const handleOk = async () => {
	const result = await hyFormRef.value?.check();
	if (result) {
		loading.value = true;
		threeListEditApi({ applyReason: hyFormRef.value.hyForm.applyReason, businessKey: props.businessKey, businessType: props.businessType })
			.then((res: any) => {
				dialogVisible.value = false;
				emits('sendValue', res);
			})
			.finally(() => {
				loading.value = false;
			});
	}
};
defineExpose({
	dialogVisible,
});
</script>
<style scoped lang="scss"></style>
